using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApplication17
{
class Program
{
static void Main(string[] args)
{
while (true)
{
int rdmNum = snt(1, 51);
int count = 1;
while (true)
{
Console.Write("Please put a numerical value here between 1 and 50(0 to quit):");
int input = Convert.ToInt32(Console.ReadLine());
if (input == 0)
return;
else if (input < rdmNum)
{
Console.WriteLine("Sorry, This value is Low \nPlease try again...");
++count;
continue;
}
else if (input > rdmNum)
{
Console.WriteLine("Sorry, This value is High \nPlease try again.");
++count;
continue;
}
else
{
Console.WriteLine("Hi, You guessed this! The number was {0}!", rdmNum);
Console.WriteLine("It found you {0} {1}.\n", count, count == 1 ? "try" : "tries");
break;
}
}
}
}
static int snt(int min, int max)
{
Random random = new Random();
return random.Next(min, max);
}
}
}
Liked By
Write Answer
How to write a program in C# like a mini-game ?
Join MindStick Community
You have need login or register for voting of answers or question.
Anonymous User
10-Oct-2018